#include <iostream>
#include<vector>
using namespace std;

using ll = long long;
int main()
{
    int n, q;
    cin >> n >> q;
    vector<ll> arr(1, 0);
    ll ai;
    for (int i = 0; i < n; i++)
    {
        cin >> ai;
        arr.push_back(ai);
    }
    for (int i = 2; i <= n; i++)
        arr[i] += arr[i - 1];
    while (q--)
    {
        int l, r;
        cin >> l >> r;
        cout << arr[r] - arr[l - 1] << endl;
    }
    return 0;
}